package com.giscloud.limp.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;

import com.giscloud.limp.entity.CompanyBlacklist;
import com.giscloud.limp.service.CompanyBlacklistService;
import com.giscloud.limp.entity.dto.CompanyBlacklistDTO;
import com.giscloud.datasource.page.PageInfo;
import com.giscloud.commons.model.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;


/**
 * 企业黑名单
 *
 * @author giscloud
 * @email giscloud@giscloud.com
 * @date 2020-06-10 19:33:46
 */
@RestController
@RequestMapping("/limp/companyblacklist")
@Log4j2
public class CompanyBlacklistController {

    private final CompanyBlacklistService companyBlacklistService;

    @Autowired
    public CompanyBlacklistController(CompanyBlacklistService companyBlacklistService) {
        this.companyBlacklistService = companyBlacklistService;
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result<PageInfo<CompanyBlacklist>> list(@RequestBody CompanyBlacklistDTO companyBlacklistDTO){
        PageInfo page = companyBlacklistService.queryPage(companyBlacklistDTO);
        return Result.success(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{companyListId}")
    public Result<CompanyBlacklist> info(@PathVariable("companyListId") Integer companyListId){
		CompanyBlacklist companyBlacklist = companyBlacklistService.getById(companyListId);
        return Result.success(companyBlacklist);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody CompanyBlacklist companyBlacklist){
        return companyBlacklistService.save(companyBlacklist);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody CompanyBlacklist companyBlacklist){
        return companyBlacklistService.updateById(companyBlacklist);
    }

    /**
     * 删除(直接传数组对象即可，如：[1],[1,2]支持批量删除)
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Integer[] companyListIds){
        return companyBlacklistService.removeByIds(Arrays.asList(companyListIds));
    }

}
